﻿//======================================================================
//
//        Copyright (C) 苏州逸仙软件    
//        All rights reserved
//
//        filename :D_T_KnowledgeExp
//        description :知识点信息扩展类
//
//        created by Jason at  2010-12-13 17：49
//
//======================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using huaguwang;
using System.Data.SqlClient;


namespace huaguwang
{
    public class D_T_KnowledgeExp : D_T_Knowledge
    {
        /// <summary>
        /// 分页获取数据量
        /// </summary>
        /// <returns></returns>
        public int GetPageCount()
        {
            string strSQL = ExpandMSSQL.GetPageSQL(
               "T_Knowledge a inner join T_Category b on a.CateID = b.id ",
               "a.flag =1 and b.flag =1");
            var PageCount = strSQL.Exp_GetSingle(MSSQLHelper.SQLConType.C1);
            return PageCount.Exp_IntTryParse();
        }

        /// <summary>
        /// 分页获取数据信息
        /// </summary>
        /// <param name="Begin">起始目录</param>
        /// <param name="Size">每页显示的数量</param>
        /// <returns></returns>
        public List<M_T_Knowledge> GetPageList(int Begin,int Size)
        {
            string strSQL = ExpandMSSQL.GetPageSQL(
                Begin,
                Size,
                "a.id,a.Title,a.UploadDate,a.Contents,b.NewsCateName",
                "T_Knowledge a inner join T_Category b on a.CateID = b.id",
                "a.id",
                "a.flag =1 and b.flag =1",
                "a.UploadDate desc");
            var List = strSQL.Exp_GetList(MSSQLHelper.SQLConType.C1,
                DR => new M_T_Knowledge()
                {
                    id=DR["id"].Exp_Trim(),
                    Title =DR["Title"].Exp_Trim(),
                    UploadDate=DR["UploadDate"].Exp_DateTimeTryParse(),
                    Contents =DR["Contents"].Exp_Trim().Exp_SubStringByLength(100,""),
                    ColorKey = DR["NewsCateName"].Exp_Trim()
                });
            return List;
        }


    }
}
